package com.um.jdy.platform.market.manager;

import com.um.jdy.common.market.entity.dto.ActivityGoodsDTO;
import com.um.jdy.common.market.entity.po.ActivityGoods;
import com.um.jdy.common.market.entity.vo.ActivityGoodsVO;
import com.um.jdy.common.market.service.ActivityGoodsService;
import com.um.jdy.platform.market.entity.dto.ActivityGoodsPageDTO;
import com.um.jdy.platform.market.entity.dto.ActivityPageDTO;
import com.um.jdy.platform.shop.entity.dto.GoodsPageDTO;
import com.um.jdy.platform.shop.entity.vo.GoodsPageVO;
import com.um.springboot.starter.config.SystemSQL;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.manager.BaseManager;
import com.um.springboot.starter.orm.manager.BasePlusManager;
import com.um.springboot.starter.orm.params.ListDTO;
import com.um.springboot.starter.utils.StringUtil;
import org.springframework.stereotype.Component;

/**
 * 管理类：活动商品表
 */
@Component
public class ActivityGoodsManager extends BasePlusManager<ActivityGoodsService, ActivityGoods, ActivityGoodsDTO, ActivityGoodsVO, ActivityGoodsPageDTO, ListDTO> {

    public Page<GoodsPageVO> getActivityGoodsPage(ActivityGoodsPageDTO pageDTO) {
        Page<GoodsPageVO> page = new Page<>();
        page.setPageNo(pageDTO.getPageNo());
        page.setPageSize(pageDTO.getPageSize());

        String goodsName = StringUtil.getTrim(pageDTO.getShopGoodsName(), "%");
        String isUpper = StringUtil.getTrim(pageDTO.getIsUpper(), "%");

        String sql = SystemSQL.getInstance().getSystemSQL("get_activity_goods_page");

        String sumSql = SystemSQL.getInstance().getSystemSQL("get_activity_goods_count");

        page = service.getViewModelPageBySql(page, sql, sumSql, GoodsPageVO.class, new Object[]{isUpper,getComId(),getComId(),goodsName});
        return page;
    }

}
